home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / a86v311c.arc / 12COMPAT.DOC < prev    next >
Encoding:
Text File  |  1987-09-25  |  9.7 KB  |  209 lines

  1. CHAPTER 12   COMPATIBILITY WITH OTHER ASSEMBLERS          12-1
  2.  
  3.  
  4. I gave heavy priority to compatibility when I designed A86; a
  5. priority just a shade behind the higher priorities of
  6. reliability, speed, convenience, and power.  For those of you who
  7. feel that "close, but incompatible" is like saying "a little bit
  8. pregnant", I'm sorry to report that A86 will not assemble all
  9. Intel/IBM/MSDOS programs, unmodified. But I do think that a vast
  10. majority of programs can, with a surprisingly little amount of
  11. massaging, be made to assemble under A86.  Furthermore, the
  12. massaging can be done in such a way as to make the programs still
  13. acceptable to that old, behemoth assembler.
  14.  
  15. Version 3.00 of A86 has many compatibility features not present
  16. on earlier versions.  Among the features added since A86 was
  17. first released are:  more general forward references, double-
  18. quotes for strings, "=" as a synonym for EQU, the RADIX
  19. directive, and the COMMENT directive.  If you tried feeding an
  20. old source file to a previous A86 and were dismayed by the number
  21. of error messages you got, try again: things might be more
  22. manageable now.
  23.  
  24.  
  25. Conversion of Intel/IBM/MSDOS programs to A86
  26.  
  27. Following is a list of the things you should watch out for when
  28. converting from Intel/IBM to A86:
  29.  
  30. 1. If your program does not fit into 64K, with all the segment
  31.    registers pointing to the same value, then there may be
  32.    instructions in the program for which the old assembler
  33.    generates segment-override prefixes "behind your back".  You
  34.    will need to find such references, and generate explicit
  35.    overrides for them.  If there are data-tables within the
  36.    program itself, a CS-override is needed.    If there are data-
  37.    structures in the stack segment not accessed via a BP-index,
  38.    an SS-override is needed. If ES points to its own segment,
  39.    then an ES-override is needed for accesses (other than STOS
  40.    and MOVS destinations) to that segment.
  41.  
  42.    If you want to remain compatible with the old assembler, then
  43.    you code the overrides by placing the segment register name,
  44.    with a colon, before the memory-access operand in the
  45.    instruction.  If you do not need further compatibility, you
  46.    can place the segment register name before the instruction
  47.    mnemonic.  For example:
  48.  
  49.     MOV AL,CS:TABLE[SI]   ; if you want compatibility do this
  50.     CS MOV AL,TABLE[SI]   ; if not you can do it this way
  51.  
  52. 2. A86 is a bit more restrictive with respect to forward-
  53.    references than IBM's assembler, but not as much as it used to
  54.    be.  You'll probably need to resolve just a few ambiguous
  55.    references by appending " B" or " W" to the forward-reference
  56.    name.
  57.                                                           12-2
  58. 3. A86 has the feature, not seen in Intel/IBM, that the default
  59.    base for numbers with leading digit 0 is hexadecimal, not
  60.    decimal.  This means that you must remove any leading zeroes
  61.    from decimal numbers in your old programs.  Note that all
  62.    constants other than those without leading zeroes and without
  63.    trailing base-specifiers are handled identically by A86 and by
  64.    Intel/IBM.  The ONLY thing you need to worry about is decimal
  65.    numbers with leading zeroes.  Example: the old code line MOV
  66.    AX,00100, meaning decimal 100, should be recoded MOV AX,100,
  67.    without the leading zeroes.
  68.  
  69.    Alternatively, I have added the RADIX command, for
  70.    compatibility with the .RADIX command of IBM's assembler.  If
  71.    the program has a .RADIX command at the top of it, then my
  72.    assembler will handle constants identically to the IBM
  73.    assembler; if it does not, you can add a .RADIX 10 to the top
  74.    of the program, for complete compatibility.
  75.  
  76.    For even greater convenience, I have added the +D switch,
  77.    which you can put into your A86 environment variable, to
  78.    achieve decimal functionality without a RADIX 10 command.
  79.  
  80. 4. A86's macro definition language is different than Intel/IBM's.
  81.    Most macros can be translated by replacing the named
  82.    parameters of the old macros with the dedicated names #n of
  83.    the A86 macro language; and by replacing ENDM with #EM.  To
  84.    retain compatibility, you isolate the old macro definitions in
  85.    an INCLUDE file (A86 will ignore the INCLUDE directive), and
  86.    isolate the A86 macro definitions in a separate file, not used
  87.    in an Intel/IBM assembly of the program.
  88.  
  89. 5. A86 does not support a couple of the more exotic features of
  90.    Intel/IBM assembly language: the RECORD directive and its
  91.    associated operators WIDTH and MASK; and the usage of angle-
  92.    brackets to initialize structure-records.  These features
  93.    would have added much complication to the internal structure
  94.    of symbol tables in A86; degrading the speed and the
  95.    reliability of the assembler.  I felt that their use was
  96.    sufficiently rare that it was not worth including them for
  97.    compatibility.  I would like to hear some feedback on this.
  98.    Does anybody out there use these features heavily?  Will they
  99.    be missed in A86?
  100.  
  101.    If your old program does use these features, you will have to
  102.    re-work the areas that use them.  Macros can be used to
  103.    duplicate the record and structure initializations.  Explicit
  104.    symbol declarations can replace the usage of the WIDTH and
  105.    MASK operators.
  106.  
  107.                                                           12-3
  108. Compatibility-symbols recognized by A86
  109.  
  110. A86 has been programmed to ignore a variety of lines that have
  111. meaning to Intel/IBM/MSDOS assemblers; but which do nothing for
  112. A86.  These include lines beginning with a period (except .RADIX,
  113. which is acted upon), percent sign, or dollar sign; and lines
  114. beginning with ASSUME, INCLUDE, PAGE, SUBTTL, and TITLE. If you
  115. are porting your program to A86, and you wish to retain the
  116. option of returning to the other assembler, you may leave those
  117. lines in your program.  If you decide to stay with A86, you can
  118. remove those lines at your leisure.
  119.  
  120. In addition, there is a class of symbols now recognized by A86 in
  121. its .OBJ mode, but still ignored in .COM mode.  This includes
  122. NAME, END, and PUBLIC.
  123.  
  124. Named SEGMENT and ENDS directives written for other assemblers
  125. are, of course, recognized by A86's OMF mode.  In non-OMF mode,
  126. A86 treats these as CODE SEGMENT directives.  A special exception
  127. to this is the directive
  128.  
  129.     segname SEGMENT AT atvalue
  130.  
  131. which is treated by A86 as if it were the following sequence:
  132.  
  133.     segname EQU atvalue
  134.     STRUC
  135.  
  136. This will accomplish what is usually intended when SEGMENT AT is
  137. used in a program intended to be a COM file.
  138.  
  139.  
  140.  
  141. Conversion of A86 Programs to Intel/IBM/MSDOS
  142.  
  143. I consider this section a bit of a blasphemy, since it's a little
  144. silly to port programs from a superior assembler, to run on an
  145. inferior one.  However, I myself have been motivated to do so
  146. upon occasion, when programming for a client not familiar with
  147. A86; or whose computer doesn't run A86; who therefore wants the
  148. final version to assemble on Intel's assembler.  Since my
  149. assembler/debugger environment is so vastly superior to any other
  150. environment, I develop the program using my assembler, and port
  151. it to the client's environment at the end.
  152.  
  153. The main key to success in following the above scenarios is to
  154. exercise supreme will power, and not use any of the wonderful
  155. language features that exist on A86, but not on the Intel/IBM
  156. assembler.  This is often not easy; and I have devised some
  157. methods for porting my features to Intel/IBM assemblers:
  158.                                                           12-4
  159. 1. I hate giving long sequences of PUSHes and POPs on separate
  160.    lines.  If the program is to be ported to a lesser assembler,
  161.    then I put the following lines into a file that only A86 will
  162.    see:
  163.  
  164.       PUSH2 EQU PUSH
  165.       PUSH3 EQU PUSH
  166.       POP2 EQU POP
  167.       POP3 EQU POP
  168.  
  169.    I define macros PUSH2, PUSH3, POP2, POP3 for the lesser
  170.    assembler, that PUSH or POP the appropriate number of
  171.    operands.  Then, everywhere in the program where I would
  172.    ordinarily use A86's multiple PUSH/POP feature, I use one or
  173.    more of the PUSHn/POPn mnemonics instead.
  174.  
  175. 2. I refrain from using the feature of A86 whereby constants with
  176.    a leading zero are default-hexadecimal.  All my hex constants
  177.    end with H.
  178.  
  179. 3. I will usually go ahead and use my local labels L0 through L9;
  180.    then at the last minute convert them to a long sequence of
  181.    labels in sequence: Z100, Z101, Z102, etc.  I take care to
  182.    remove all the ">" forward-reference specifiers when I make
  183.    the conversion.  The "Z" is used to isolate the local labels
  184.    at the end of the lesser assembler's symbol-table listing.
  185.    This improves the quality of the final program so much that it
  186.    is worth the extra effort needed to convert L0--L9's to Z100-
  187.    Zxxx's.
  188.                                                           12-5
  189. 4. I will place declarations B EQU DS:BYTE PTR 0 and W EQU
  190.    DS:WORD PTR 0 at the top of the program.  Recall that A86 has
  191.    a "duplicate definition" feature whereby you can EQU an
  192.    already-existing symbol, as long as it is equated to the value
  193.    it already has.  This feature extends to the built in symbols
  194.    B and W, so A86 will look at those equates and essentially
  195.    ignore them.  On the old assembler, the effect of the
  196.    declarations is to add A86's notation to the old language.
  197.    Example:
  198.  
  199.          B EQU DS:BYTE PTR 0
  200.          W EQU DS:WORD PTR 0
  201.          MOV AX,W[0100]    ; replaces MOV AX, DS:WORD PTR 0100
  202.          MOV AL,B[BX]      ; replaces MOV AL, DS:BYTE PTR [BX]
  203.  
  204.    Note that I've just given you a tip that means even if you
  205.    don't choose to use A86, you'll never have to use BYTE PTR or
  206.    WORD PTR again!  Now don't you just hate BYTE PTR and WORD
  207.    PTR?  Isn't the tip alone worth sending me at least $5 for?
  208.  
  209.